﻿//----------------------------------------------------------------------------------------------------
// A Level contains all the information for a level. (duh)
//----------------------------------------------------------------------------------------------------

package HG.GameDataTypes
{
	import flash.utils.ByteArray;
	import HG.GameDataTypes.NodeInstance;
	import HG.Debug;
	
	import flash.net.registerClassAlias;
	

	public class Level
	{
		public var m_nodes:Array;
		public var m_name:String;
		public var m_gameType:Number;
		
		//----------------------------------------------------------------------------------------------------
		public function Level()
		{
			registerClassAlias("Level", Level);
			
			m_nodes = new Array();
			
			m_name = "Unknown";
			m_gameType = 0;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function AddNode(node:NodeInstance)
		{
			m_nodes.push(node);
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetName(name:String)
		{
			m_name = name;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetName():String
		{
			return m_name;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetGameType(gameType:Number)
		{
			m_gameType = gameType;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetGameType():Number
		{
			return m_gameType;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetNodes():Array
		{
			return m_nodes;
		}
	
		//----------------------------------------------------------------------------------------------------
		public function ToString():String
		{
			Debug.ASSERT(m_nodes, "Invalid Node Collection");
			
			var output:String = "";
			
			var index:Number = 0;
			var listLength:Number = m_nodes.length;
			for (index = 0; index < listLength; ++index)
			{
				var node:NodeInstance = m_nodes[index]; 
				
				Debug.ASSERT(node, "Attempted to get invalid level node: " + index);
				
				output += node.ToString();
			}
			return output;
		}
	}
}